home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / gs24src.zip / GS_2ASC.PS < prev    next >
Text File  |  1991-12-08  |  4KB  |  109 lines

  1. %    Copyright (C) 1991 Aladdin Enterprises.  All rights reserved.
  2. %    Distributed by Free Software Foundation, Inc.
  3. %
  4. % This file is part of Ghostscript.
  5. %
  6. % Ghostscript is distributed in the hope that it will be useful, but
  7. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. % to anyone for the consequences of using it or for whether it serves any
  9. % particular purpose or works at all, unless he says so in writing.  Refer
  10. % to the Ghostscript General Public License for full details.
  11. %
  12. % Everyone is granted permission to copy, modify and redistribute
  13. % Ghostscript, but only under the conditions described in the Ghostscript
  14. % General Public License.  A copy of this license is supposed to have been
  15. % given to you along with Ghostscript so you can know your rights and
  16. % responsibilities.  It should be in a file named COPYING.  Among other
  17. % things, the copyright notice and this notice must be preserved on all
  18. % copies.
  19.  
  20. % Extract the ASCII text from a PostScript file.  Nothing is displayed.
  21. % Instead, lines are written to stdout as follows:
  22. %    F <height> - indicate font height
  23. %    S <x> <y> (<string>) - display a string
  24. %    P - end of page
  25. % <height> is an integer expressed in device pixels.
  26. % <x> and <y> are integer device coordinates.  <string> is a string
  27. % represented with the standard PostScript escape conventions.
  28. % The idea is similar to Glenn Reid's `distillery', only a lot more
  29. % simple-minded, and less robust.
  30.  
  31. % Note that this code will only work properly if systemdict is writable.
  32. % For this reason, it is normally read in by gs_init.ps before
  33. % systemdict is made read-only.
  34.  
  35. /QUIET true def
  36. systemdict wcheck { systemdict } { userdict } ifelse begin
  37.  
  38. % Disable the display operators.
  39.  
  40. /eofill { newpath } odef
  41. /erasepage { } odef
  42. /fill { newpath } odef
  43. /stroke { newpath } odef
  44.  
  45. % Image and imagemask must read the input, but do nothing.
  46.  
  47. /image { gsave nulldevice //image grestore } odef
  48. /imagemask { gsave nulldevice //imagemask grestore } odef
  49.  
  50. % Redefine the end-of-page operators.
  51.  
  52. /copypage { (P\n) //print } odef
  53. /showpage { copypage erasepage } odef
  54.  
  55. % Redefine `show'.
  56.  
  57. /.show.ident matrix def
  58. /.showfont
  59.  { 0 currentfont /FontBBox get dup 3 get exch 1 get sub
  60.    currentfont /FontMatrix get dtransform dtransform
  61.    exch abs exch abs max round
  62.    (F ) //print //.stdout exch write==only (\n) //print
  63.  } odef
  64. /.showstring
  65.  { gsave //.show.ident setmatrix
  66.    (S ) //print currentpoint
  67.    exch round dup //.stdout exch write==only ( ) //print
  68.    exch round dup //.stdout exch write==only ( ) //print
  69.    moveto dup //.stdout exch write==only (\n) //print
  70.    grestore stringwidth rmoveto
  71.  } odef
  72. /show
  73.  { .showfont .showstring
  74.  } odef
  75.  
  76. % Redefine the other string display operators in terms of `show'.
  77.  
  78. /.show1 { ( ) dup 0 3 index put exch pop .showstring } odef
  79. /ashow
  80.  { .showfont
  81.    { .show1 2 copy rmoveto } forall
  82.    exch neg exch neg rmoveto
  83.  } odef
  84. /widthshow
  85.  { .showfont
  86.    { 2 copy .show1 eq { 1 index 1 index rmoveto } if } forall
  87.    pop pop pop
  88.  }
  89. /awidthshow
  90.  { .showfont
  91.    { dup .show1 3 index eq { 4 index 4 index rmoveto } if
  92.      2 copy rmoveto
  93.    } forall
  94.    exch neg exch neg rmoveto
  95.    pop pop pop
  96.  }
  97. /kshow
  98.  { .showfont
  99.    { .show1 dup exec } forall pop
  100.  } odef
  101.  
  102. % Redirect the printing operators.
  103.  
  104. /.stdout (_temp_.out) (w) file def
  105. /.stderr (_temp_.err) (w) file def
  106. /print { //.stdout exch writestring } odef
  107.  
  108. end
  109.